package components;

import java.util.ArrayList;

import android.graphics.Canvas;

public class Layer {
	
	private boolean valid;
	private ArrayList<GraphicalObject> graphicalObjects; 
	
	public Layer(){
		valid = true;
		graphicalObjects = new ArrayList<GraphicalObject>();
	}
	
	public void draw(Canvas c){
		for(GraphicalObject currentObject : graphicalObjects){
			//we let each object draw itself as proposed by android
			currentObject.draw(c);
		}
	}
	
	public void invalidate() {
		this.valid = false;
	}
	
	public void validate(){
		for(GraphicalObject currentObject : graphicalObjects){
			//we let each object draw itself as proposed by android
			currentObject.validate();
		}
	}

	public boolean isValid() {
		boolean valid = true;
		for(GraphicalObject currentObject : graphicalObjects){
			//we let each object draw itself as proposed by android
			valid = valid && currentObject.isValid();
		}
		return valid;
	}

}
